import React, { useState, useEffect, useRef } from 'react';
import {useHistory} from 'react-router-dom';
import AlignItemsList from '../components/meeting_list'
import axios from 'axios';
import { Fetch } from "../utils/fetch";

import { firstApi } from "../services/myrequest";

export default function LiveList() {


  
//  axios.defaults.withCredentials = true
//  axios.get('http://127.0.0.1:3000/api/index_category')
//   .then(function (response) {
//     console.log('request success!!!!')
//     console.log(response);
//   })
//   .catch(function (error) {
//     console.log(error);
//   });

//   axios.get('/api/index_category')
//   .then(function (response) {
//     console.log('request success!!!!')
//     console.log(response);
//   })
//   .catch(function (error) {
//     console.log(error);
//   });


 const data= firstApi.getFisrtList()
 console.log(data);
 data.then(function(res) {
   console.log(res);
  // success
}, function(error) {
  // failure
});
 

interface Config {
  type:string;
  url:string;
  data?:string;
  dataType:string
}

function ajax(config:Config){

var xhr = new XMLHttpRequest()
xhr.open(config.type,config.url,true)
xhr.send(config.data);
xhr.onreadystatechange =function(){
  if(xhr.readyState==4 && xhr.status==200){
      console.log('success')
  }
  else{
      console.log(xhr.responseText)
  }
}

}
ajax({
  type:'get',
  url:'http:localhost:4000/api/index_category',
  data:'name:zhangsna',
  dataType:'json'
})
　

  


    
    return (
      <div >
         <AlignItemsList></AlignItemsList>
        
      </div>
    )
  }
  